<?php

class ControllerWpActivity extends Controller
{
    private $error = array();

    public  function getList(){
        $this->load->model('wp/activity');
        if (! $this->actionCheck(true, false)) {
            return;
        }


        $data = $this->model_wp_activity->getList(  $this->customer->getId(),$this->request->get['pageNum'],$this->request->get['pageSize']);

        $this->load->model('tool/image');
        foreach ($data as &$item){
            if(empty($item['thumb'])){
                $item['thumb'] = HTTP_IMAGE . 'image/' . 'no_image.png';//$this->model_tool_image->resize('no_image.png', 100, 100);
            }
            else{
                $item['thumb'] = HTTP_IMAGE . 'image/' . $item['thumb'] ;// $this->model_tool_image->resize($item['thumb'], 100, 100);
            }

        }

        $this->response->setOK( $data);
    }
    public function getItem()
    {
        $this->load->model('wp/activity');
        if (! $this->actionCheck(true, false)) {
            return;
        }


        $data = $this->model_wp_activity->getItem($this->customer->getId(),$this->request->get['id']);
        $this->response->setOK( $data);

    }

    public function unReadCount()
    {
        $this->load->model('wp/activity');
        if (! $this->actionCheck(true, false)) {
            return;
        }


        $data = $this->model_wp_activity->unReadCount($this->customer->getId());
        $this->response->setOK( $data);

    }


    public function UserList()
    {
        $this->load->model('wp/activity');
        if (! $this->actionCheck(false, false)) {
            return;
        }


        $data = $this->model_wp_activity->getUserList();
        $this->response->setOK( $data);

    }

    public function Comment()
    {
        $this->load->model('wp/activity');
        if (! $this->actionCheck(true, true)) {
            return;
        }


        $this->model_wp_activity->comment($this->request->post['page_id'],$this->request->post['message'],
            $this->customer->getId(),$this->customer->getFirstName());
        $this->response->setOK( );

    }
}